import React from 'react';
import { Form, Row, DatePicker, Button, Select, Input, Col } from 'antd';
const FormItem = Form.Item;
const { Option } = Select;

const SearchForm = ({ form: { getFieldDecorator, getFieldsValue }, onSearch,searchItem ,resetForm}) => {

  const formItemLayout = {
    // 抽屉里面Form。二列的布局比例
    labelCol: {
      span: 6
    },
    wrapperCol: {
      span: 16
    }
  };
  return (
    <Form className="search-form">
      <Row gutter={24}>
        <Col span={5}>
          <FormItem label="物料编码"{...formItemLayout}>
            {getFieldDecorator('partCode',{
              initialValue : searchItem.partCode || ''
            })(
              <Input placeholder='请输入物料编码' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="图号"{...formItemLayout}>
            {getFieldDecorator('paperCode',{
              initialValue : searchItem.paperCode || ''
            })(
              <Input placeholder='请输入图号' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="物料名称"{...formItemLayout}>
            {getFieldDecorator('partName',{
              initialValue : searchItem.partName || ''
            })(
              <Input placeholder='请输入物料名称' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={5}>
          <FormItem label="仓库"{...formItemLayout}>
            {getFieldDecorator('storeName',{
              initialValue : searchItem.storeName || ''
            })(
              <Input placeholder='请输入仓库' allowClear onPressEnter={() => onSearch(getFieldsValue())} />
            )}
          </FormItem>
        </Col>
        <Col span={4} style={{ display: 'flex' }} className="serarch-btns">
          <FormItem>
            <Button icon="search" type="primary" onClick={() => onSearch(getFieldsValue())}>
              {'查询'}
            </Button>
          </FormItem>
          {/* <FormItem>

            <Button type="primary" icon={advanced ? 'up' : 'down'} onClick={() => onHandleAdvanced()}>
              {'展开'}
            </Button>
          </FormItem> */}
          <FormItem>

            <Button type="default" icon={'redo'} onClick={() => resetForm()}>
              {'重置'}
            </Button>
          </FormItem>
        </Col>
      </Row>
    </Form>
  );
};

export default Form.create()(SearchForm);
